package com.doit.demo03;

import javax.lang.model.element.VariableElement;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class fele_client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.2.160", 9999);
        FileInputStream in = new FileInputStream("C:\\Users\\DHG\\Desktop\\于和伟.mp4");
        OutputStream out = socket.getOutputStream();

        byte[] bytes = new byte[1024];
        int len ;
        while ((len=in.read(bytes))!=-1){
            out.write(bytes,0,len);
        }
        socket.shutdownOutput();//告知服务器 上传完毕

        InputStream inn = socket.getInputStream();
        byte[] bytes1 = new byte[1024];
        int lenn=inn.read(bytes1);
            System.out.println(new String(bytes1,0,lenn));


        inn.close();
        out.close();
        in.close();
        socket.close();
    }
}
